package com.bfs.anasit.model;

import com.bfs.anasit.model.embeddable.Name;
import com.bfs.core.model.BaseModel;
import org.hibernate.annotations.Cascade;
import org.hibernate.validator.constraints.NotEmpty;

import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Model;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;


/**
 * Created by IntelliJ IDEA.
 * User: lukman
 * Date: 6/12/11
 * Time: 9:34 PM
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Named
@Dependent
public class AnasitUser extends BaseModel {

    private Long id;
    private String userName;
    private String passString;
    @Inject
    private Name name;

    @Inject
    private AnasitRole role;


    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @NotEmpty
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @NotNull
    public String getPassString() {
        return passString;
    }

    public void setPassString(String passString) {
        this.passString = passString;
    }

    @Embedded
    public Name getName() {
        return name;
    }

    public void setName(Name name) {
        this.name = name;
    }

    @JoinColumn
    @ManyToOne(cascade = CascadeType.ALL)
    public AnasitRole getRole() {
        return role;
    }

    public void setRole(AnasitRole roles) {
        this.role = roles;
    }
}
